package dkzcm.club.article.infra.basic.service.impl;

import dkzcm.club.article.infra.basic.entity.ArticleCategory;
import dkzcm.club.article.infra.basic.mapper.ArticleCategoryDao;
import dkzcm.club.article.infra.basic.service.ArticleCategoryService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 分类表(ArticleCategory)表服务实现类
 *
 * @author makejava
 * @since 2024-11-29 23:22:12
 */
@Service("articleCategoryService")
public class ArticleCategoryServiceImpl implements ArticleCategoryService {
    @Resource
    private ArticleCategoryDao articleCategoryDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ArticleCategory queryById(Long id) {
        return this.articleCategoryDao.queryById(id);
    }



    /**
     * 新增数据
     *
     * @param articleCategory 实例对象
     * @return 实例对象
     */
    @Override
    public ArticleCategory insert(ArticleCategory articleCategory) {
        this.articleCategoryDao.insert(articleCategory);
        return articleCategory;
    }

    /**
     * 修改数据
     *
     * @param articleCategory 实例对象
     * @return 实例对象
     */
    @Override
    public ArticleCategory update(ArticleCategory articleCategory) {
        this.articleCategoryDao.update(articleCategory);
        return this.queryById(articleCategory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.articleCategoryDao.deleteById(id) > 0;
    }

    @Override
    public List<ArticleCategory> queryPrimaryCategory() {
        return this.articleCategoryDao.queryPrimaryCategory();
    }
}
